﻿

using System;
using System.Windows.Forms;
using loginWinForm.content;
using loginWinForm.entity;
using loginWinForm.form;
using loginWinForm.service;
using loginWinForm.service.impl;

namespace loginWinForm
{
    public partial class login : Form
    {
        private ILoginService loginService = new LoginService();

        public login()
        {
            InitializeComponent();
        }

        private void login_Click(object sender, EventArgs e)
        {
            string name = nameBox.Text;
            string password = passwordBox.Text;

            if (name.Length <= 0)
            {
                MessageBox.Show("请输入用户名");
                return;
            }
            if (password.Length <= 0)
            {
                MessageBox.Show("请输入密码");
                return;
            }


            SysUser user = loginService.GetUserByName(name);
            if (null == user)
            {
                MessageBox.Show("用户名不存在");
                return;
            }
            if (!password.Equals(user.Name))
            {
                MessageBox.Show("用户名或密码错误");
                return;
            }

            this.Hide();
            CONTENT.SysUser = user;
            new Success().Show();
        }


        private void register_Click(object sender, EventArgs e)
        {
            this.Hide();
            new Register().Show();
        }

    }
}
